<template>
  <div class="setting-container">
    <van-nav-bar title="消息中心" left-arrow @click-left="this.$router.go(-1)" />
    <div class="setting-cotent">
      <div class="card" @click="showNotice(item)" v-for="item in noticelist" :key="item.id">
        <div class="left">
          <img src="../../assets/image/logo.jpg" alt="" />
          <div class="main">
            <p class="name">系统通知</p>
            <!-- <p class="comment gray">emmmmm</p> -->
          </div>
        </div>
        <p class="right gray">{{ item.createTime }}</p>
      </div>
    </div>
  </div>
</template>

<script>
import { showDialog, showToast } from 'vant'
import { getNotice } from '../../api/user.js'
export default {
  data() {
    return {
      noticelist: []
    }
  },
  created() {
    this.getNoticeList()
  },
  methods: {
    async getNoticeList() {
      const { data: res } = await getNotice()
      if (res.code === 1) {
        this.noticelist = res.data
      } else {
        showToast('获取数据失败！')
      }
    },
    showNotice(item) {
      showDialog({
        title: '通知',
        message: item.wenben
      }).then(() => {
        this.showRule = false
      })
    }
  }
}
</script>

<style lang="less" scoped>
.setting-container {
  height: 100vh;

  .van-nav-bar {
    background-color: #55c24d;
    :deep(.van-icon) {
      color: #fff;
    }
    :deep(.van-nav-bar__title) {
      color: #fff;
      font-size: 16px;
      font-weight: 500;
    }
  }

  .setting-cotent {
    width: 100%;

    .card {
      display: flex;
      justify-content: space-between;
      border-bottom: 1px solid #666;
      padding: 10px;
      margin: 0 10px 15px 10px;
      background-color: #fff;

      p {
        margin: 8px 0;
      }

      .left {
        display: flex;
        justify-content: start;
        align-items: center;
        img {
          width: 50px;
          height: 50px;
          border-radius: 50%;
          margin-right: 5px;
        }
      }
    }
  }
}

.gray {
  color: #999;
}
</style>
